- /* sfffcomp.cpp by K.Tsuru */
- // function ID = 7001 DRADIX
- /****************************************************************
- SFraction class
- It provides the comparison of two abusolute values and
- returns sgn(|m| - |n|) = 1, 0 , -1.
- m = m.num/m.den; n = n.num/n.den;
- |m| - |n| = ( |m.num|*n.den - m.den*|n.num| ) / (m.den*n.den);
- ****************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- int FFCompare(const SFraction& m, const SFraction& n){
- //check the diffrence between the number of figures.
- //error is one or under, 99*99 (2+2) = 891*11 (3+2)
- int df;
- df = (int)(m.NumNR().Head()+n.DenNR().Head()) - int(m.DenNR().Head()+n.NumNR().Head());
- if(abs(df) > 1) return Sgn(df); //obvious differnce in the number of figures
- SLong a, b;
- a = m.NumNR()*n.DenNR(); b = m.DenNR()*n.NumNR();
- return LLCompare(a, b);
- }
sfffcomp.cpp : last modifiled at 2014/05/22 15:52:58(886 bytes)
created at 2015/12/22 16:07:29
The creation time of this html file is 2016/09/13 19:56:38 (Tue Sep 13 19:56:38 2016).